package com.two.user.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.two.user.service.UserService;
import com.two.user.service.impl.UserServiceImpl;


@WebServlet("/updateUser.do")
public class updateUserServlet extends HttpServlet{

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("UTF-8");
		String id = req.getParameter("id");
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		String age = req.getParameter("age");
		String gender = req.getParameter("gender");
		String remake = req.getParameter("remark");
		UserService service = new UserServiceImpl();
		boolean result = service.updateUser(id, username, password, age, gender, remake);
		System.out.println("更新结果：" + result);
		req.getRequestDispatcher("view/Liang/user.html").forward(req, resp);
	}
	
}
